﻿using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using TianShu.Service.Contracts.Service.Crud;
using TianShu.Service.Dtos;
using TianShu.TenantManagement.Service.Abstracts.TenantService.Dtos;
using TianShu.WebApi;

namespace TianShu.TenantManagement.WebApi.Controllers
{

    public class TenantController : TianShuCrudController<Guid, TenantDto, TenantCreateDto, TenantUpdateDto>
    {
        ITenantAppService _tenantService;
        public TenantController(ITenantAppService tenantService) : base(tenantService)
        {
            this._tenantService = tenantService;
        }

        [HttpGet("[action]")]
        public async Task<PageResultDto<object>> GetDefaultConnectionString(Guid id)
        {
            return await _tenantService.GetDefaultConnectionStringAsync(id);
        }

        [HttpPost("[action]")]
        public async Task<PageResultDto<bool>> UpdateDefaultConnectionString(Guid id, TenantConnectionStringUpdateInput input)
        {
            return await _tenantService.UpdateDefaultConnectionStringAsync(id, input);
        }

        [HttpPut("[action]")]
        public async Task<PageResultDto<bool>> DeleteDefaultConnectionString(Guid id)
        {
            return await _tenantService.DeleteDefaultConnectionStringAsync(id);
        }
    }
}